{% extends "manage/layout.html" %}

{% set page_title = '展会管理' %}

{% block css %}
<style type="text/css">
	#createmodal .modal-body{
		margin:20px 0 10px 10%;
	}
	.classroom{
		color: red;
	}
	.system{
		color: #545454;
	}
</style>
{% endblock %}

{% block content %}
<div class="m-content">
    {% if current_user.has_permission('EDIT') -%}
    <a class="btn btn-default" id="create_group" href="javascript:;">创建微信分组</a>
    {%- endif %}
    <a class="btn btn-primary" href="{{ url_for('manage.exhibitions') }}">展会信息</a>
	<table class="table table-striped table-condensed table-bordered table-hover">
		<thead>
			<tr>
				<th>分组id</th>
				<th>名称</th>
				<th>人数</th>
			</tr>
		</thead>
		<tbody>
			{% for group in groups['groups'] -%}
                {% if group.id > 103 -%}
			<tr id="{{ group.id }}">
				<td>{{ group.id }}</td>
				<td>{{ group.name }}</td>
				<td>{{ group.count }}</td>
			</tr>
                {%- endif %}
			{%- endfor %}
		</tbody>
	</table>
</div>

<div class="modal modal-confirm">
	<div class="modal-dialog modal-md">
		<div class="modal-content">
			<div class="modal-header">
				<h4 class="modal-title">创建微信分组</h4>
			</div>
			<div class="modal-body">
                <form class="form-horizontal" id="createGroupForm" method="POST" action="{{ url_for('manage.wx_group_add') }}">
                    <div class="form-group">
                        <label for="group_name" class="col-sm-2 control-label">分组名称</label>
                        <div class="col-sm-10">
                        <input type="text" class="form-control" id="group_name" name="group_name" placeholder="最多六个汉字或12个英文字符" maxlength="12" required>
                        </div>
                    </div>
                </form>
			</div>
            <div class="modal-footer">
				<button class="btn btn-danger">确认</button>
				<button class="btn btn-default btn-close">取消</button>
            </div>
		</div>
	</div>
</div>
{% endblock %}

{% block js%}
<script>
$(function(){

	// click trash
	$('#create_group').click(function(){
		var exh_id = $(this).parent().parent().parent().attr('id');
		$('.modal-confirm').modal('show');

		// click modal alert confirm button
		$('.modal-confirm .btn-danger').bind('click',function(){
            $('#createGroupForm').submit()
		});
	});

	// click modal alert confirm/cancal button
	$('.modal-confirm .btn-close').bind('click',function(){
		$('.modal-confirm').modal('hide');
	});
});
</script>
{% endblock %}
